package com.qst.action.AssessmentType;

import com.qst.BaseServlet;
import com.qst.RequestUtil;
import com.qst.WebUtil;
import com.qst.entity.AssessmentType;
import com.qst.service.AssessmentService;
import com.qst.service.impl.ServiceFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@WebServlet("/assessment/view.action")
public class ViewServlet extends BaseServlet {

    private AssessmentService assessmentService = ServiceFactory
            .getService(AssessmentService.class);

    @Override
    protected void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = RequestUtil.getInt(req, "id");
        // String str = req.getParameter("id");
        // int id = Integer.parseInt(str);
        AssessmentType assessment = assessmentService.findAssessmentById(id);
        req.setAttribute("assessment", assessment);
        WebUtil.forward(req, resp, "/assessment/view.jsp");
    }
}
